// pages/promise/index.js
const SERVER = require('../../utils/index');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    show:false,
    array: ['10000', '20000', '30000', '40000','50000', '60000', '70000', '80000','90000', '100000'],
    index:'0'
  },
  zhifu(){
    
    var that=this
    let param = {
      quotaLevel : 2,
      depositAmount : '1000',
      depositType : 1,
      payMode:2,
     
    }
    wx.request({//首页数据
      url: '' + SERVER.SERVER_DIMAIN + '/customer/depositorder/payQuotaOrder', 
      data: JSON.stringify(param),
      header: {
        'content-type': 'application/json' ,
        "TENANT-ID":"2",
        "Connection":'Keep-alive',
        "Accept-Encoding":'gzip,deflate,br',
        "Authorization":"Bearer "+wx.getStorageSync('token'),
        "DEVICE_TYPE":'IOS'
      },
      method: 'post',
      success: function (res) {
        let data=JSON.parse(res.data.data)
        console.log(data)
      console.log(JSON.stringify(data.timestamp))
        wx.requestPayment(
          {

            timeStamp: JSON.stringify(data.timestamp),
            nonceStr: data.noncestr,
            package: data.package,
            signType:'',
            paySign: data.sign,
            
            success: function (res) {
             console.log(res)
             
            },
            fail: function (res) { 
              console.log(res)
            },
            complete: function (res) { 
              console.log(res)
            }
          })
      //  that.setData({
      //    list:res.data.data.records
      //  })
  
       
      }
    });
  },
  showit(){
    this.setData({
      show:true
    })
  },
  showits(){
    this.setData({
      show:false
    })
  },
  
  // onClose() {
  //   this.setData({ show: false });
  // },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },
  bindPickerChange: function(e) {
    console.log('picker发送选择改变，携带值为', e.detail.value)
    this.setData({
      index: e.detail.value
    })
  },
  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})